<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"lianyouli.gitee.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="使用flink mysql cdc 来采集mysql bin日志文件时，发现其使用guava18与flink的flink streaming依赖guava30冲突。Compatibility problem with Flink 1.14.* · Issue #1010 · ververica&#x2F;flink-cdc-connectors (github.com)">
<meta property="og:type" content="article">
<meta property="og:title" content="flink 1.14.4使用flink mysql cdc connector 2.2时报guava18、guava30和blink冲突问题">
<meta property="og:url" content="https://lianyouli.gitee.io/IT/it-bigdata-flink-cdc-guava18-blink-conflicts/index.html">
<meta property="og:site_name" content="联友的Blog">
<meta property="og:description" content="使用flink mysql cdc 来采集mysql bin日志文件时，发现其使用guava18与flink的flink streaming依赖guava30冲突。Compatibility problem with Flink 1.14.* · Issue #1010 · ververica&#x2F;flink-cdc-connectors (github.com)">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-flink-cdc-guava18-blink-conflicts/%E7%BD%91%E9%A1%B5%E6%8D%95%E8%8E%B7_1-5-2022_175624_gitee.com.jpeg">
<meta property="article:published_time" content="2022-05-01T09:59:11.000Z">
<meta property="article:modified_time" content="2022-05-01T10:51:05.088Z">
<meta property="article:author" content="李联友">
<meta property="article:tag" content="streaming">
<meta property="article:tag" content="bigdata">
<meta property="article:tag" content="cdc">
<meta property="article:tag" content="flink">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://lianyouli.gitee.io/IT/it-bigdata-flink-cdc-guava18-blink-conflicts/%E7%BD%91%E9%A1%B5%E6%8D%95%E8%8E%B7_1-5-2022_175624_gitee.com.jpeg">

<link rel="canonical" href="https://lianyouli.gitee.io/IT/it-bigdata-flink-cdc-guava18-blink-conflicts/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>flink 1.14.4使用flink mysql cdc connector 2.2时报guava18、guava30和blink冲突问题 | 联友的Blog</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?eb9f10e46b1f09801805fc668f13d477";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="联友的Blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">联友的Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">密涅瓦的猫头鹰在黄昏起飞</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">25</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">8</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">31</span></a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://lianyouli.gitee.io/IT/it-bigdata-flink-cdc-guava18-blink-conflicts/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/header.jpg">
      <meta itemprop="name" content="李联友">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="联友的Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          flink 1.14.4使用flink mysql cdc connector 2.2时报guava18、guava30和blink冲突问题
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2022-05-01 17:59:11 / 修改时间：18:51:05" itemprop="dateCreated datePublished" datetime="2022-05-01T17:59:11+08:00">2022-05-01</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IT/" itemprop="url" rel="index"><span itemprop="name">IT</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <blockquote>
<p>使用flink mysql cdc 来采集mysql bin日志文件时，发现其使用guava18与flink的flink streaming依赖guava30冲突。<a href="https://github.com/ververica/flink-cdc-connectors/issues/1010" target="_blank" rel="noopener">Compatibility problem with Flink 1.14.* · Issue #1010 · ververica/flink-cdc-connectors (github.com)</a></p>
</blockquote>
<a id="more"></a>

<h2 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h2><ul>
<li>Flink 与 blink合并了，现在没有blink了。</li>
<li>Flink-MySQL-CDC-Connector  2.2.x官方提示支持1.14.x和1.13.x，其实是只支持1.13.x。 具体请参考： <a href="https://ververica.github.io/flink-cdc-connectors/release-2.2/content/about.html#supported-connectors" target="_blank" rel="noopener">FLINK CDC</a></li>
</ul>
<h2 id="环境"><a href="#环境" class="headerlink" title="环境"></a>环境</h2><ul>
<li>MacOS Monterey</li>
<li>Oracle JDK 11.0.12 (x86_64) </li>
<li>Scala 2.12.4</li>
<li>Flink 1.14.4</li>
<li>MySQL 8.0.28 </li>
</ul>
<h2 id="解决方法"><a href="#解决方法" class="headerlink" title="解决方法"></a>解决方法</h2><ul>
<li>pom.xml删除blink依赖</li>
<li>将代码中的guava18替换成guava30</li>
</ul>
<blockquote>
<p>有些地方我做了暴力处理，例如把所有测试代码都删除了，还有一些maven插件也删除了。如果有朋友处理好了，也请告诉我学习学习。</p>
</blockquote>
<p>下图是在我自己的repository里修改的地方，供参考。</p>
<p><img src="/IT/it-bigdata-flink-cdc-guava18-blink-conflicts/%E7%BD%91%E9%A1%B5%E6%8D%95%E8%8E%B7_1-5-2022_175624_gitee.com.jpeg" alt="网页捕获_1-5-2022_175624_gitee.com"></p>
<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><h3 id="pom-xml"><a href="#pom-xml" class="headerlink" title="pom.xml"></a>pom.xml</h3><blockquote>
<p> 不能添加mysql-connector-java依赖，因为flink-connector-mysql-cdc中已经包含了mysql driver，否则会报错</p>
<p>com.mysql.cj.CharsetMapping.getJavaEncodingForMysqlCharset(Ljava/lang/String;)Ljava/lang/String</p>
</blockquote>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">&lt;!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment"> &lt;dependency&gt;</span></span><br><span class="line"><span class="comment">            &lt;groupId&gt;mysql&lt;/groupId&gt;</span></span><br><span class="line"><span class="comment">            &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</span></span><br><span class="line"><span class="comment">            &lt;version&gt;8.0.28&lt;/version&gt;</span></span><br><span class="line"><span class="comment"> &lt;/dependency&gt;</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.ververica<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>flink-connector-mysql-cdc<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.2-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- https://mvnrepository.com/artifact/com.ververica/flink-connector-debezium --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.ververica<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>flink-connector-debezium<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.2-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- https://mvnrepository.com/artifact/org.apache.flink/flink-shaded-guava --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.flink<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>flink-shaded-guava<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>30.1.1-jre-14.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="scala代码"><a href="#scala代码" class="headerlink" title="scala代码"></a>scala代码</h3><figure class="highlight scala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> local.sleety.flink.quickstart.sensor</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.ververica.cdc.connectors.mysql.source.<span class="type">MySqlSource</span></span><br><span class="line"><span class="keyword">import</span> com.ververica.cdc.debezium.<span class="type">StringDebeziumDeserializationSchema</span></span><br><span class="line"><span class="keyword">import</span> org.apache.flink.api.common.eventtime.<span class="type">WatermarkStrategy</span></span><br><span class="line"><span class="keyword">import</span> org.apache.flink.streaming.api.scala._</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.<span class="type">Properties</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">object</span> <span class="title">SensorMySQLCDCDB</span> </span>&#123;</span><br><span class="line">  <span class="function"><span class="keyword">def</span> <span class="title">main</span></span>(args: <span class="type">Array</span>[<span class="type">String</span>]): <span class="type">Unit</span> = &#123;</span><br><span class="line">    <span class="keyword">val</span> debeziumProperties = <span class="keyword">new</span> <span class="type">Properties</span>()</span><br><span class="line">    debeziumProperties.put(<span class="string">"snapshot.locking.mode"</span>, <span class="string">"none"</span>)</span><br><span class="line">    <span class="keyword">val</span> mysqlSource = <span class="type">MySqlSource</span>.builder[<span class="type">String</span>]()</span><br><span class="line">      .debeziumProperties(debeziumProperties)</span><br><span class="line">      .hostname(<span class="string">"localhost"</span>)</span><br><span class="line">      .port(<span class="number">3306</span>)</span><br><span class="line">      .databaseList(<span class="string">"tests"</span>)</span><br><span class="line">      <span class="comment">// tableList is a mandatory option</span></span><br><span class="line">      .tableList(<span class="string">"tests.sensor"</span>, <span class="string">"tests.sensor2"</span>)</span><br><span class="line">      <span class="comment">// it doesn't support the regex</span></span><br><span class="line">      <span class="comment">//      .tableList("tests.sensor*")</span></span><br><span class="line">      .username(<span class="string">"nifi"</span>)</span><br><span class="line">      .password(<span class="string">"secret"</span>)</span><br><span class="line">      .deserializer(<span class="keyword">new</span> <span class="type">StringDebeziumDeserializationSchema</span>())</span><br><span class="line">      .build()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">val</span> env = <span class="type">StreamExecutionEnvironment</span>.getExecutionEnvironment</span><br><span class="line">    env.enableCheckpointing(<span class="number">3000</span>)</span><br><span class="line">    env.fromSource(mysqlSource,</span><br><span class="line">      <span class="type">WatermarkStrategy</span>.noWatermarks(),</span><br><span class="line">      <span class="string">"MySQL CDC Source"</span>)</span><br><span class="line">      .setParallelism(<span class="number">1</span>)</span><br><span class="line">      .print(<span class="string">"MySQLCDC DB"</span>).setParallelism(<span class="number">1</span>)</span><br><span class="line">    env.execute()</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="DDL"><a href="#DDL" class="headerlink" title="DDL"></a>DDL</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">--------------------------------------------------------------------</span></span><br><span class="line"><span class="comment">--  flink lab sensor </span></span><br><span class="line"><span class="comment">--------------------------------------------------------------------</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- tests.sensor definition</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> <span class="string">`sensor`</span> (</span><br><span class="line">  <span class="string">`id`</span> <span class="built_in">varchar</span>(<span class="number">10</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span>,</span><br><span class="line">  <span class="string">`ts`</span> <span class="built_in">bigint</span> <span class="keyword">NOT</span> <span class="literal">NULL</span>,</span><br><span class="line">  <span class="string">`temperature`</span> <span class="built_in">decimal</span>(<span class="number">18</span>,<span class="number">12</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span>,</span><br><span class="line">  PRIMARY <span class="keyword">KEY</span> (<span class="string">`id`</span>)</span><br><span class="line">) <span class="keyword">ENGINE</span>=<span class="keyword">InnoDB</span> <span class="keyword">DEFAULT</span> <span class="keyword">CHARSET</span>=utf8mb4 <span class="keyword">COLLATE</span>=utf8mb4_0900_ai_ci;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">-- tests.sensor2 definition</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> <span class="string">`sensor2`</span> (</span><br><span class="line">  <span class="string">`id`</span> <span class="built_in">int</span> <span class="keyword">NOT</span> <span class="literal">NULL</span> AUTO_INCREMENT,</span><br><span class="line">  <span class="string">`name`</span> <span class="built_in">varchar</span>(<span class="number">10</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span>,</span><br><span class="line">  <span class="string">`ts`</span> <span class="built_in">bigint</span> <span class="keyword">unsigned</span> <span class="keyword">NOT</span> <span class="literal">NULL</span>,</span><br><span class="line">  <span class="string">`temperature`</span> <span class="built_in">decimal</span>(<span class="number">21</span>,<span class="number">15</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span>,</span><br><span class="line">  PRIMARY <span class="keyword">KEY</span> (<span class="string">`id`</span>)</span><br><span class="line">) <span class="keyword">ENGINE</span>=<span class="keyword">InnoDB</span> AUTO_INCREMENT=<span class="number">3</span> <span class="keyword">DEFAULT</span> <span class="keyword">CHARSET</span>=utf8mb4 <span class="keyword">COLLATE</span>=utf8mb4_0900_ai_ci;</span><br></pre></td></tr></table></figure>



<h3 id="输出示例"><a href="#输出示例" class="headerlink" title="输出示例"></a>输出示例</h3><h4 id="insert"><a href="#insert" class="headerlink" title="insert"></a>insert</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; insert into sensor2(name, ts, temperature) values ('sensor_2', 1650585135196, 26.842860145725);</span><br><span class="line"></span><br><span class="line">Query OK, 1 row affected (0.00 sec)</span><br></pre></td></tr></table></figure>

<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">MySQLCDC DB&gt; SourceRecord&#123;sourcePartition=&#123;server=mysql_binlog_source&#125;, sourceOffset=&#123;transaction_id=null, ts_sec=1651401623, file=binlog.000014, pos=5872, row=1, server_id=1, event=2&#125;&#125; ConnectRecord&#123;topic='mysql_binlog_source.tests.sensor2', kafkaPartition=null, key=Struct&#123;id=1&#125;, keySchema=Schema&#123;mysql_binlog_source.tests.sensor2.Key:STRUCT&#125;, </span><br><span class="line">value=Struct&#123;</span><br><span class="line">after=Struct&#123;id=1,name=sensor_2,ts=1650585135196,temperature=26.842860145725000&#125;,</span><br><span class="line">source=Struct&#123;version=1.5.4.Final,connector=mysql,name=mysql_binlog_source,ts_ms=1651401623000,db=tests,table=sensor2,server_id=1,file=binlog.000014,pos=6014,row=0&#125;,</span><br><span class="line">op=c,</span><br><span class="line">ts_ms=1651401623109&#125;, </span><br><span class="line">valueSchema=Schema&#123;mysql_binlog_source.tests.sensor2.Envelope:STRUCT&#125;, timestamp=null, headers=ConnectHeaders(headers=)&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; insert into sensor2(name, ts, temperature) values ('sensor_1', 1650585135196, 46.842020145725);</span><br><span class="line"></span><br><span class="line">Query OK, 1 row affected (0.00 sec)</span><br></pre></td></tr></table></figure>

<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">MySQLCDC DB&gt; SourceRecord&#123;sourcePartition=&#123;server=mysql_binlog_source&#125;, sourceOffset=&#123;transaction_id=null, ts_sec=1651401631, file=binlog.000014, pos=6191, row=1, server_id=1, event=2&#125;&#125; ConnectRecord&#123;topic='mysql_binlog_source.tests.sensor2', kafkaPartition=null, key=Struct&#123;id=2&#125;, keySchema=Schema&#123;mysql_binlog_source.tests.sensor2.Key:STRUCT&#125;, </span><br><span class="line">value=Struct&#123;</span><br><span class="line">after=Struct&#123;id=2,name=sensor_1,ts=1650585135196,temperature=46.842020145725000&#125;,</span><br><span class="line">source=Struct&#123;version=1.5.4.Final,connector=mysql,name=mysql_binlog_source,ts_ms=1651401631000,db=tests,table=sensor2,server_id=1,file=binlog.000014,pos=6333,row=0&#125;,</span><br><span class="line">op=c,</span><br><span class="line">ts_ms=1651401631597&#125;, </span><br><span class="line">valueSchema=Schema&#123;mysql_binlog_source.tests.sensor2.Envelope:STRUCT&#125;, timestamp=null, headers=ConnectHeaders(headers=)&#125;</span><br></pre></td></tr></table></figure>

<h4 id="update"><a href="#update" class="headerlink" title="update"></a>update</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; update sensor2 set temperature=50.2342234232 where name = 'sensor_1';</span><br><span class="line"></span><br><span class="line">Query OK, 1 row affected (0.00 sec)</span><br><span class="line"></span><br><span class="line">Rows matched: 1 Changed: 1 Warnings: 0</span><br></pre></td></tr></table></figure>

<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">MySQLCDC DB&gt; SourceRecord&#123;sourcePartition=&#123;server=mysql_binlog_source&#125;, sourceOffset=&#123;transaction_id=null, ts_sec=1651401638, file=binlog.000014, pos=6510, row=1, server_id=1, event=2&#125;&#125; ConnectRecord&#123;topic='mysql_binlog_source.tests.sensor2', kafkaPartition=null, key=Struct&#123;id=2&#125;, keySchema=Schema&#123;mysql_binlog_source.tests.sensor2.Key:STRUCT&#125;, </span><br><span class="line">value=Struct&#123;</span><br><span class="line">before=Struct&#123;id=2,name=sensor_1,ts=1650585135196,temperature=46.842020145725000&#125;,</span><br><span class="line">after=Struct&#123;id=2,name=sensor_1,ts=1650585135196,temperature=50.234223423200000&#125;,</span><br><span class="line">source=Struct&#123;version=1.5.4.Final,connector=mysql,name=mysql_binlog_source,ts_ms=1651401638000,db=tests,table=sensor2,server_id=1,file=binlog.000014,pos=6661,row=0&#125;,</span><br><span class="line">op=u,</span><br><span class="line">ts_ms=1651401638156&#125;, </span><br><span class="line">valueSchema=Schema&#123;mysql_binlog_source.tests.sensor2.Envelope:STRUCT&#125;, timestamp=null, headers=ConnectHeaders(headers=)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="delete"><a href="#delete" class="headerlink" title="delete"></a>delete</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; delete from sensor2 where name = 'sensor_1';</span><br><span class="line"></span><br><span class="line">Query OK, 1 row affected (0.00 sec)</span><br></pre></td></tr></table></figure>

<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">MySQLCDC DB&gt; SourceRecord&#123;sourcePartition=&#123;server=mysql_binlog_source&#125;, sourceOffset=&#123;transaction_id=null, ts_sec=1651401643, file=binlog.000014, pos=6871, row=1, server_id=1, event=2&#125;&#125; ConnectRecord&#123;topic='mysql_binlog_source.tests.sensor2', kafkaPartition=null, key=Struct&#123;id=2&#125;, keySchema=Schema&#123;mysql_binlog_source.tests.sensor2.Key:STRUCT&#125;, </span><br><span class="line">value=Struct&#123;</span><br><span class="line">before=Struct&#123;id=2,name=sensor_1,ts=1650585135196,temperature=50.234223423200000&#125;,</span><br><span class="line">source=Struct&#123;version=1.5.4.Final,connector=mysql,name=mysql_binlog_source,ts_ms=1651401643000,db=tests,table=sensor2,server_id=1,file=binlog.000014,pos=7013,row=0&#125;,</span><br><span class="line">op=d,</span><br><span class="line">ts_ms=1651401643147&#125;, v</span><br><span class="line">alueSchema=Schema&#123;mysql_binlog_source.tests.sensor2.Envelope:STRUCT&#125;, timestamp=null, headers=ConnectHeaders(headers=)&#125;</span><br></pre></td></tr></table></figure>




    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/streaming/" rel="tag"># streaming</a>
              <a href="/tags/bigdata/" rel="tag"># bigdata</a>
              <a href="/tags/cdc/" rel="tag"># cdc</a>
              <a href="/tags/flink/" rel="tag"># flink</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/IT/it-bigdata-nifi-mysql-cdc/" rel="prev" title="Nifi Mysql CDC">
      <i class="fa fa-chevron-left"></i> Nifi Mysql CDC
    </a></div>
      <div class="post-nav-item">
    <a href="/uncategorized/it-bigdata-distributed-sql-query-engine-trino/" rel="next" title="初探trino">
      初探trino <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#背景"><span class="nav-number">1.</span> <span class="nav-text">背景</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#环境"><span class="nav-number">2.</span> <span class="nav-text">环境</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解决方法"><span class="nav-number">3.</span> <span class="nav-text">解决方法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用"><span class="nav-number">4.</span> <span class="nav-text">使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#pom-xml"><span class="nav-number">4.1.</span> <span class="nav-text">pom.xml</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#scala代码"><span class="nav-number">4.2.</span> <span class="nav-text">scala代码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#DDL"><span class="nav-number">4.3.</span> <span class="nav-text">DDL</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#输出示例"><span class="nav-number">4.4.</span> <span class="nav-text">输出示例</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#insert"><span class="nav-number">4.4.1.</span> <span class="nav-text">insert</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#update"><span class="nav-number">4.4.2.</span> <span class="nav-text">update</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#delete"><span class="nav-number">4.4.3.</span> <span class="nav-text">delete</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="李联友"
      src="/images/header.jpg">
  <p class="site-author-name" itemprop="name">李联友</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">31</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/lianyouli" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lianyouli" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">李联友</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

<script src="/js/jquery.min.js"> </script>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>



<script src="/js/code-unfold.js"></script>


  















  

  

</body>
</html>
